var _common_util = require('util/common_util.js');

var _user_service = {

    login : function (userInfo, resolve, reject){
        _common_util.request({
            url         : _common_util.getServerURL('user/login'),
            data        : userInfo,
            method      : 'POST',
            success     : resolve,
            error       : reject
        });
    },


    checkLogin : function (resolve, reject){
        _common_util.request({
            url         : _common_util.getServerURL('user/get_user_info'),
            success     : resolve,
            error       : reject
        });
    },

    logout : function (resolve, reject){
        _common_util.request({
            url         : _common_util.getServerURL('user/logout'),
            method      : 'POST',
            success     : resolve,
            error       : reject
        });
    },

    register : function (userInfo, resolve, reject){
        _common_util.request({
            url         : _common_util.getServerURL('user/register'),
            data        : JSON.stringify(userInfo),
            method      : 'POST',
            contentType : "application/json;charsetset=UTF-8",//必须
            success     : resolve,
            error       : reject
        });
    },

};

module.exports = _user_service;